package app.species.ANN;

//the link class in the network, has weights, weighcaps, etc
//just stores the incoming/outgoing values of an axon at a timestep
public class Axon extends Cell{

	/**
	 * 
	 */
	private static final long serialVersionUID = -3148809632320109419L;

	private static double MAX_WEIGHT = 50.0;

	private double weight;
	
	private boolean mode = true;
	public Axon(int id, double w){
		this(id,w,true);
	}

	public Axon(int id, double w,boolean modus){

		super(id);

		this.setWeight(w);
		mode = modus;

	}

	//pushes incoming values thru the weight, and puts it as an output
	public void fire(){

		if(mode)this.output = this.weight * this.input;
		else this.output = this.weight + this.input;

		this.input = 0;

	}
	
	public void setMode(boolean b){
		mode = b;
	}
	public boolean getMode(){
		return mode;
	}

	// set the weight and make sure it's within the correct range
	public void setWeight(double w){

		if(w < -Axon.MAX_WEIGHT) this.weight = -Axon.MAX_WEIGHT;
		else if(w > Axon.MAX_WEIGHT) this.weight = Axon.MAX_WEIGHT;
		else this.weight = w;

	}
	public double getWeight(){
		return weight;
	}

	public static void setMaxWeight(double d){
		Axon.MAX_WEIGHT = d;
	}

	public static double getMaxWeight(){
		return Axon.MAX_WEIGHT;
	}

}
